<template>
  <div>
    <script :id=id type="text/plain"></script>
  </div>
</template>
<script>
import { mapState, mapActions } from 'vuex';
  export default {
    name: 'UE',
    // computed:mapState(['defaultMsg']),
    data () {
      return {
        editor: null
      }
    },
    props: {
      defaultMsg: {
        type: String
      },
      config: {
        type: Object
      },
      id: {
        type: String
      }
    },
    mounted() {
      const _this = this;
      this.editor = UE.getEditor(this.id, this.config); // 初始化UE
      this.editor.addListener("ready", function () {
      _this.editor.setContent(_this.defaultMsg); // 确保UE加载完成后，放入内容。
      // _this.$store.commit('DEFAULTMSG',_this.defaultMsg);
        // _this.editor.setContent('<p>new text</p>', true);
      });
    },
    methods: {
      getUEContent() { // 获取内容方法
        return this.editor.getContent()
      }
    },
    destroyed() {
      this.editor.destroy();
    }
  }
</script>